#ifndef MATHHELPER_H
#define MATHHELPER_H

#include <math.h>

namespace CExpression
{
class MathHelper
{
public:
	static const double COMPARE_PRECISION_DEFAULT;

	static bool Equal(double num1,double num2,double precision)
	{
		return abs(num1-num2)<=precision;
	}

	static double Round(double num,int decimals)
	{
		if(num>0)
		{
			return static_cast<int>(num*10*decimals+0.5)/10.0*decimals;
		}
		else
		{
			return static_cast<int>(num*10*decimals-0.5)/10.0*decimals;
		}
	}
};
}

#endif